#!/usr/bin/python
# -*- coding: utf-8 -*-
from Tkinter import*
chtv = False
px = 15
i = 0
def motion(event):
	print("Mouse position: (%s %s)" % (event.x, event.y))
	if event.y % 5 == 0:
		print "Yes"
	return
def callback(event):
	global px,line,i
	print "clicked at", event.x, event.y
	if event.y % 5 == 0:
		if chtv == True:
			can.create_oval(px,event.y-5,px+10,event.y+5,fill = "black")
			can.create_line(px+10,event.y,px+10,event.y-40)
			px = px + 35
			if px >= 735:
				px = 10
			i = i + 1
			if i == 4 or i == 8 or i == 12 or i == 16 or i == 20 or i == 24:
				can.create_line(px+10,line-10,px+10,line-50)
				px = px + 40
def stan():
	global line
	i = 0
	line = 100
	while i < 5:
		can.create_line(5,line,735,line)
		line = line + 10
		i = i + 1
root = Tk()
can = Canvas(root,width = 740,height = 700)	
can.pack()
can.bind("<Button-1>", callback)
can.bind('<Motion>',motion)
can.pack()
inp = raw_input("введите длительность ноты: 4 , 8 :")
if inp == "4":
	chtv = True
stan()
root.mainloop()  
